package com.ruoyi.ucar.mapper;

import java.util.List;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.ruoyi.ucar.domain.TBrandPrice;
import com.ruoyi.ucar.domain.po.BrandPriceDetailPo;
import com.ruoyi.ucar.domain.po.BrandPriceListPo;
 import com.ruoyi.ucar.moreq.BrandPriceDetailQueryMoReq;
import com.ruoyi.ucar.moreq.BrandPriceListQueryMoReq;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * 车辆品牌价格Mapper接口
 *
 * @author ruoyi
 * @date 2025-07-02
 */
@Mapper
public interface TBrandPriceMapper extends BaseMapper<TBrandPrice>
{
    /**
     * 查询车辆品牌价格
     * @param id 车辆品牌价格主键
     * @return 车辆品牌价格
     */
    TBrandPrice selectTBrandPriceById(Long id);

    /**
     * 查询车辆品牌价格列表
     * @param tBrandPrice 车辆品牌价格
     * @return 车辆品牌价格集合
     */
    List<TBrandPrice> selectTBrandPriceList(TBrandPrice tBrandPrice);

    /**
     * 删除车辆品牌价格
     * @param id 车辆品牌价格主键
     * @return 结果
     */
    int deleteTBrandPriceById(Long id);

    /**
     * 批量删除车辆品牌价格
     * @param ids 需要删除的数据主键集合
     * @return 结果
     */
    int deleteTBrandPriceByIds(Long[] ids);

    @Select("<script>" +
            "SELECT  " +
            "   bp.ID as id,  " +
            "   bp.BRAND_PRICE_UUID as brandPriceUuid,  " +
            "   bp.VEHICLE_BRAND as vehicleBrand,  " +
            "   bp.PRICE as price,  " +
            "   bp.REAL_PRICE as realPrice,  " +
            "   bp.PURCHASING_PRICE as purchasingPrice,  " +
            "   bp.RETURN_PRICE as returnPrice,  " +
            "   bp.PRODUCT_TYPE as productType  " +
            "FROM  " +
            "   t_brand_price bp  " +
            "<where>" +
            "   <if test='queryParams.deleteFlag != null'>" +
            "       AND bp.DELETE_FLAG = #{queryParams.deleteFlag}  "+
            "   </if>" +
            "   <if test='queryParams.id != null'> AND bp.id = #{queryParams.id} </if>" +
            "   <if test='queryParams.brandPriceUuid != null and queryParams.brandPriceUuid != \"\"'> AND bp.BRAND_PRICE_UUID = #{queryParams.brandPriceUuid} </if>" +
            "</where>" +
            "</script>")
    List<BrandPriceDetailPo>  brandPriceDetailQuery( @Param("queryParams") BrandPriceDetailQueryMoReq brandPriceDetailQueryMoReq);


    @Select("<script>" +
            "SELECT  " +
            "   bp.ID as id,  " +
            "   bp.BRAND_PRICE_UUID as brandPriceUuid,  " +
            "   bp.VEHICLE_BRAND as vehicleBrand,  " +
            "   bp.PRICE as price,  " +
            "   bp.REAL_PRICE as realPrice,  " +
            "   bp.PURCHASING_PRICE as purchasingPrice,  " +
            "   bp.RETURN_PRICE as returnPrice,  " +
            "   bp.PRODUCT_TYPE as productType  " +
            "FROM  " +
            "   t_brand_price bp  " +
            "<where>" +
            "   <if test='queryParams.deleteFlag != null'>" +
            "       AND bp.DELETE_FLAG = #{queryParams.deleteFlag}  "+
            "   </if>" +
            "   <if test='queryParams.vehicleBrand != null and queryParams.vehicleBrand != \"\"'>AND bp.VEHICLE_BRAND LIKE CONCAT('%',#{queryParams.vehicleBrand},'%')</if>" +
            "   <if test='queryParams.productType != null and queryParams.productType != \"\"'>AND bp.PRODUCT_TYPE =#{queryParams.productType} </if>" +
            "</where>" +
            " order by bp.id desc "+
            "</script>")
    public IPage<BrandPriceListPo> brandPriceListQueryPage(IPage<BrandPriceListPo> page, @Param("queryParams") BrandPriceListQueryMoReq brandPriceListQueryMoReq);

}
